import copy

from twisted.web import server
from twisted.protocols.http import datetimeToLogString

from activist.web.resource import *


DEBUG = True

class Site(server.Site):
    """
    FIXME: copied from active2 stuff
    """
    
    def __init__(self):
        server.Site.__init__(self,None,logPath="access_log")

        self._404 = FourOhFour()
        
                                        # this will be used to remap each bit of an IP
                                        # address. every time the server restarts, the uniqueness
                                        # of IPs will be lost (unless this is saved), but at
                                        # least nobody can tell which IP requests came from while
                                        # at the same time making log analysers expecting valid
                                        # IPs not choke and keeping uniqueness (i.e. 16 requests
                                        # from one IP will have the same munged IP in the log)
        self._ipMunger = {}
        for x in range(256):
            self._ipMunger[x] = random.randint(0,256)
            if DEBUG: self._ipMunger[x] = x

    def getSession(self, uid):
        print "GETSESSION:",uid,self.sessions.keys()
        return server.Site.getSession(self,uid)
